package com.sparsearr.datastructures.itheima.choujiang;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Random;

/**
 * @Author: ZhaoTR
 * @Date: Created in 2025/4/19 17:34
 * @Description: 抽奖
 * @Version: 1.0
 */

public class CJ {
    private static final Logger logger = LogManager.getLogger(CJ.class);

    public static void main(String[] args) {
        int[] arr = {2, 588, 888, 1000, 10000};

        int[] newArr = new int[arr.length];

        Random random = new Random();
        for (int i = 0; i < 5; ) {
            int index = random.nextInt(arr.length);
            int prize = arr[index];
            if (!contains(newArr, prize)) {
                newArr[i] = prize;
                i++;
            }
        }

        for (int i = 0; i < newArr.length; i++) {
            logger.info("newArr[i] = {}", newArr[i]);
        }

    }

    private static boolean contains(int[] arr, int prize) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == prize) {
                return true;
            }
        }
        return false;
    }
}
